home *** CD-ROM | disk | FTP | other *** search
- #pragma pack(2)
-
- #include <Common.h>
- #include <System/SysAll.h>
- #include <UI/UIAll.h>
- // from an article by
- // Edward Keyes, Daggerware, mistered@1stresource.com
- // in PDA Developers 4.6, Nov/Dec 96
- void GraySwitchDisplayMode
- (short int mode, unsigned char **displayaddr)
- // This performs all the register accesses to switch
- // between grayscale and black and white modes.
- // The displayaddr variable is used in the following way:
- // on calling this procedure, load displayaddr with a
- // pointer to the address of the new display starting
- // address. The function will return a pointer to the
- // old address in the same way. The calling procedure is
- // responsible for saving and then giving back the old
- // black and white display starting address.
- // (mode=1 is switch to grayscale, mode=0 is switch to
- // black and white)
- {
- ULong *SSA;
- unsigned char *VPW,*PICF,*FRCM,*LBAR,*CKCON;
- unsigned char *oldstart;
- SSA=(ULong *)0xFFFFFA00;
- VPW=(unsigned char *)0xFFFFFA05;
- PICF=(unsigned char *)0xFFFFFA20;
- FRCM=(unsigned char *)0xFFFFFA31;
- LBAR=(unsigned char *)0xFFFFFA29;
- CKCON=(unsigned char *)0xFFFFFA27;
- if (mode==1) { //switch to grayscale
- // save old display starting address
- oldstart=(unsigned char *)*SSA;
- //switch off LCD update temporarily
- *CKCON=*CKCON & 0x7F;
- //set new display starting address
- *SSA=(ULong)*displayaddr;
- //virtual page width now 40 bytes (160 pixels)
- *VPW=20;
- *PICF=*PICF | 0x01; //switch to grayscale mode
- *LBAR=20; //line buffer now 40 bytes
- //register to control grayscale pixel oscillations
- *FRCM=0xB9;
- //let the LCD get to a new frame (20ms delay)
- SysTaskDelay(2);
- //switch LCD back on in new mode
- *CKCON=*CKCON | 0x80;
- //return original display address for switch back
- *displayaddr=oldstart;
- }
- else if (mode==0) { //switch to black and white
- //save old display starting address
- oldstart=(unsigned char *)*SSA;
- //switch off LCD update temporarily
- *CKCON=*CKCON & 0x7F;
- //set new display starting address
- *SSA=(ULong)*displayaddr;
- //virtual page width now 20 bytes (160 pixels)
- *VPW=10;
- *PICF=*PICF & 0xFE; //switch to black and white mode
- *LBAR=10; // line buffer now 20 bytes
- //let the LCD get to a new frame (20ms delay)
- SysTaskDelay(2);
- //switch LCD back on in new mode
- *CKCON=*CKCON | 0x80;
- //return original display address for switch back
- *displayaddr=oldstart;
- }
- }
-
-
- void GraySetPalette
- (short int gray0, short int gray1, short int gray2,
- short int gray3)
- // This sets the palette of the 4 active shades of gray
- // out of a selection of 7. The four parameters represent
- // the shades of the 00, 01, 10, and 11 bit patterns,
- // respectively. The palette of 7 is as follows, in
- // terms of darkness density:
- // 0=0/16, 1=4/16, 2=5/16, 3=8/16, 4=11/16, 5=12/16,
- // 6=16/16, and 7=16/16. There are two active bit values
- // for solid black; either will work.
- {
- Word *GPMR;
- Word temp;
- GPMR=(Word *)0xFFFFFA32;
- *GPMR=gray2 + (gray3<<4) + (gray0<<8) + (gray1<<12);
- }
-
-